package com.feilong.modules.client.auth;

import com.feilong.modules.client.auth.hystrix.AuthClientHystrix;
import com.feilong.modules.common.request.WxOperateDbRequest;
import com.feilong.modules.model.goods.request.GetUploadRequest;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;


@FeignClient(name = "auth-wx-cloud", url="${feilongshop.wx-cloud.url-prefix}", fallback = AuthClientHystrix.class)
public interface AuthClient {

    /**
     * 获取微信小程序AccessToken
     * @param APPID
     * @param APPSECRET
     * @return
     */
    @GetMapping(value = "/cgi-bin/token?grant_type=client_credential&appid={APPID}&secret={APPSECRET}",
            headers = {"content-type=application/json;charset=UTF-8"})
    String getAccessToken(@PathVariable(value = "APPID") String APPID, @PathVariable(value = "APPSECRET") String APPSECRET);

    /**
     * 获取上传文件链接
     * @param getUploadRequest
     * @param token
     * @return
     */
    @PostMapping(value = "/tcb/uploadfile?access_token={token}",
            headers = {"content-type=application/json;charset=UTF-8"})
    String getUploadUrl(@RequestBody GetUploadRequest getUploadRequest, @PathVariable(value = "token") String token);

    /**
     * 从微信云开发服务器查询记录
     * @param wxOperateDbRequest
     * @param token
     * @return
     */
    @PostMapping(value = "/tcb/databasequery?access_token={token}",
            headers = {"content-type=application/json;charset=UTF-8"})
    String queryCloudDbInfo(@RequestBody WxOperateDbRequest wxOperateDbRequest, @PathVariable(value = "token") String token);

    /**
     * 在微信云开发服务器插入记录
     * @param wxOperateDbRequest
     * @param token
     * @return
     */
    @PostMapping(value = "/tcb/databaseadd?access_token={token}",
            headers = {"content-type=application/json;charset=UTF-8"})
    String insertCloudDbInfo(@RequestBody WxOperateDbRequest wxOperateDbRequest, @PathVariable(value = "token") String token);

    /**
     * 在微信云开发服务器删除记录
     * @param wxOperateDbRequest
     * @param token
     * @return
     */
    @PostMapping(value = "/tcb/databasedelete?access_token={token}",
            headers = {"content-type=application/json;charset=UTF-8"})
    String deleteCloudDbInfo(@RequestBody WxOperateDbRequest wxOperateDbRequest, @PathVariable(value = "token") String token);

    /**
     * 在微信云开发服务器更新记录
     * @param wxOperateDbRequest
     * @param token
     * @return
     */
    @PostMapping(value = "/tcb/databaseupdate?access_token={token}",
            headers = {"content-type=application/json;charset=UTF-8"})
    String updateCloudDbInfo(@RequestBody WxOperateDbRequest wxOperateDbRequest, @PathVariable(value = "token") String token);

}
